#!/bin/bash

echo "=== 启动 Mianshi 项目（本地模式）==="
echo ""

echo "请确保已完成以下准备工作："
echo "1. 安装并启动MySQL数据库"
echo "2. 执行数据库初始化脚本：mysql -u root -p < src/main/resources/init.sql"
echo "3. 确认数据库连接配置正确"
echo ""

read -p "确认已完成上述准备工作？(y/n): " confirm
if [ "$confirm" != "y" ] && [ "$confirm" != "Y" ]; then
    echo "请先完成准备工作后再启动项目"
    exit 1
fi

echo ""
echo "1. 清理和编译项目..."
mvn clean compile

if [ $? -ne 0 ]; then
    echo "Maven 编译失败！请检查Java和Maven环境"
    exit 1
fi

echo ""
echo "2. 启动内置Tomcat服务器..."
echo "项目将在 http://localhost:8080 启动"
echo "按 Ctrl+C 可停止服务器"
echo ""

mvn tomcat7:run
